package cn.jwtool.jwcache.buffer.listener.init;

import cn.jwtool.jwcache.buffer.Publisher;
import cn.jwtool.jwcache.buffer.data.JwCatchTemplate;
import cn.jwtool.jwcache.buffer.listener.EventListener;
import org.reflections.Reflections;


/**
 * @author : willian fu
 * @version : 1.0
 */
public class ListenerInit {

    public ListenerInit(){
        this.init();
    }

    private void init(){
        Reflections reflections = new Reflections();
        reflections.getSubTypesOf(EventListener.class).forEach(clazz -> {
            try {
                Publisher.regListener(clazz.newInstance());
            } catch (InstantiationException | IllegalAccessException e) {
                e.printStackTrace();
                System.err.println("监听器实例化注册失败");
            }
        });

    }
}
